#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""  
@Project : pythonProject1
@File : subdomain.py
@Author : 蓝精灵
@Time : 2025/11/2 19:27  
@脚本说明 : 
"""
import concurrent.futures
import requests
import warnings

warnings.filterwarnings("ignore")


def subdomain_brute(domain, subdomain):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"
    }
    url1 = f"http://{subdomain}.{domain}"
    url2 = f"https://{subdomain}.{domain}"
    try:
        response1 = requests.get(url1, headers, timeout=10)
        if response1.status_code in [200, 301, 302, 401, 402, 403, 404, 503]:
            print(f"[+] 存在子域名 {subdomain}.{domain}")
        else:
            response2 = requests.get(url2, headers, timeout=10)
            if response2.status_code in [200, 301, 302, 401, 402, 403, 404, 503]:
                print(f"[+] 存在子域名 {subdomain}.{domain}")
    except Exception as e:
        pass


def subdomain_brute_run(domain, subdomains):
    with concurrent.futures.ThreadPoolExecutor(max_workers=10000) as executor:
        for subdomain in subdomains:
            executor.submit(subdomain_brute, domain, subdomain.strip())